package enumdemo;

public enum testEnum {
    RED("red",0),BLACK("black",1),GREEN("green",2),WHITE("white",3);

    private String name;
    private int key;
    /**
     * 1、当枚举对象有参数后，需要提供相应的构造函数
     * 2、枚举的构造函数默认是私有的 这个一定要记住
     * @param name
     * @param key
     */
    private testEnum (String name,int key) {
        this.name = name;
        this.key = key;
    }

    public static void main(String[] args) {
        testEnum[] enums = testEnum.values();
       for (testEnum anEnum : enums) {
           System.out.println(anEnum.ordinal());
        }

        System.out.println(RED.compareTo(BLACK));
        testEnum testEnum = enumdemo.testEnum.valueOf("heihei");
        System.out.println(testEnum);

    }
    public static void main1(String[] args) {
        testEnum test = testEnum.BLACK;
        switch(test){
            case RED :
                System.out.println("red");
                break;
            case BLACK:
                System.out.println("black");
                break;
            case GREEN:
                System.out.println("green");
                break;
            case WHITE:
                System.out.println("white");
                break;
            default:
                break;
        }
    }
}
